package com.jianyi.config;

import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;

public class HttpCilentConfig {

	public static RequestConfig getRequestConfig(HttpGet httpGet){
		RequestConfig requestConfig=null;
		if(httpGet.getConfig()!=null){
			requestConfig = RequestConfig.copy(httpGet.getConfig())
		            .setSocketTimeout(1000*30)
		            .setConnectTimeout(1000*30)
		            .setConnectionRequestTimeout(1000*30)
		            .build();
		}else{
			requestConfig = RequestConfig.custom()
		            .setSocketTimeout(1000*30)
		            .setConnectTimeout(1000*30)
		            .setConnectionRequestTimeout(1000*30)
		            .build();
		}
		return requestConfig;
	}
	
	public static RequestConfig getRequestConfig(HttpPost httpPost){
		RequestConfig requestConfig=null;
		if(httpPost.getConfig()!=null){
			requestConfig = RequestConfig.copy(httpPost.getConfig())
		            .setSocketTimeout(1000*30)
		            .setConnectTimeout(1000*30)
		            .setConnectionRequestTimeout(1000*30)
		            .build();
		}else{
			requestConfig = RequestConfig.custom()
		            .setSocketTimeout(1000*30)
		            .setConnectTimeout(1000*30)
		            .setConnectionRequestTimeout(1000*30)
		            .build();
		}
		return requestConfig;
	}
	
	public static HttpGet getHttpGet(String url){
		HttpGet httpGet = new HttpGet(url);
		return httpGet;
	}
}
